<template>
	<el-form label-width="130px" :model="form" :rules="rules" ref="queryForm">
		<el-row>
			<el-col :span="12">

				<el-form-item label="通信网络名称" prop="name">
					<el-input v-model="form.name" style="width: 190px;"></el-input>
				</el-form-item>

				<el-form-item label="通信网络简称" prop="shortName">
					<el-input v-model="form.shortName" style="width: 190px;"></el-input>
				</el-form-item>


				<el-form-item label="网络功能描述" prop="networkFunctionDes">
					<el-input v-model="form.networkFunctionDes" style="width: 190px;"></el-input>
				</el-form-item>

				<el-form-item label="安全等级" prop="securityLevel">
					<el-select v-model="form.securityLevel" size="default" placeholder="请选择" style="width: 190px" clearable
						filterable>
						<el-option v-for="item in SafetyOptions" :key="item.dictValue" :label="item.dictLabel"
							:value="item.dictValue" />
					</el-select>
				</el-form-item>

				<el-form-item label="网络覆盖范围" prop="networkCover">
					<el-input v-model="form.networkCover" style="width: 190px;"></el-input>
				</el-form-item>

				<el-form-item label="骨干网络带宽" prop="backboneNetwork">
					<el-input v-model="form.backboneNetwork" style="width: 190px;"></el-input>
				</el-form-item>

				<el-form-item label="频点范围" prop="frequencyPoint">
					<el-input v-model="form.frequencyPoint" style="width: 190px;"></el-input>
				</el-form-item>

				<el-form-item label="建设单位" prop="constructionUnit">
					<el-input v-model="form.constructionUnit" style="width: 190px;"></el-input>
				</el-form-item>




			</el-col>
			<el-col :span="12">

				<el-form-item label="管理单位" prop="managementUnit">
					<el-input v-model="form.managementUnit" style="width: 190px;"
						@input="e => regOnlyNumSpot(e, form, 'serialNumber', 0)"></el-input>
				</el-form-item>

				<el-form-item label="联系人" prop="contact">
					<el-input v-model="form.contact" style="width: 190px;"></el-input>
				</el-form-item>

				<el-form-item label="联系电话" prop="contactNumber">
					<el-input v-model="form.contactNumber" style="width: 190px;"></el-input>
				</el-form-item>

				<el-form-item label="网系" prop="netSeries">
					<el-select v-model="form.netSeries" size="default" placeholder="请选择" style="width: 190px" clearable
						filterable>
						<el-option v-for="item in wxOptions" :key="item.dictValue" :label="item.dictLabel"
							:value="item.dictValue" />
					</el-select>
				</el-form-item>

				<el-form-item label="来源" prop="netFrom">
					<el-select v-model="form.netFrom" size="default" placeholder="请选择" style="width: 190px" clearable
						filterable>
						<el-option v-for="item in lyOptions" :key="item.dictValue" :label="item.dictLabel"
							:value="item.dictValue" />
					</el-select>
				</el-form-item>

				<el-form-item label="网络图" prop="netPic">
					<el-input v-model="form.netPic" style="width: 190px;"></el-input>
				</el-form-item>


			</el-col>
		</el-row>

		<div style="display: flex;justify-content: flex-end;">
			<el-button @click="closethis()" @keyup.prevent @keydown.enter.prevent>取消</el-button>
			<el-button type="primary" @click="submit(queryForm)" @keyup.prevent @keydown.enter.prevent>确定</el-button>
		</div>
	</el-form>
</template>

<script setup>
	import {
		ref,
		reactive,
		onMounted
	} from 'vue'
	import {
		ElMessage
	} from 'element-plus'

	import {
		commonInterface
	} from '@/api/common/common'

	import {
		regOnlyNumSpot
	} from '@/utils/reg'

	const emit = defineEmits(['getList', 'closeWindow'])
	const props = defineProps(['editData', 'cpId', 'wxOptions', 'lyOptions','SafetyOptions'])

	const form = ref({})

	const queryForm = ref('')
	const wxOptions = ref()
	const lyOptions = ref()
	const SafetyOptions = ref()

	//必填项
	const rules = reactive({

		name: [{
			required: true,
			message: "此选项不能为空!",
			trigger: "blur"
		}]


	})
	//取消
	const closethis = () => {
		emit('closeWindow')
	}

	//确定
	const submit = async (e) => {
		if (!e) return
		await e.validate((valid) => {
			if (valid) {
				let method = 'post'
				if (props.editData) method = 'put'
				commonInterface('/back/renfang/zhtx/network/', form.value, method).then(result => {
					if (result.code === 200) {
						ElMessage.success(result.msg)
						emit('closeWindow')
						emit('getList')
					} else {
						ElMessage.error(result.msg)
					}
				})
			}
		})
	}

	onMounted(() => {
		form.value['cpId'] = props.cpId
		lyOptions.value = props.lyOptions
		wxOptions.value = props.wxOptions
		SafetyOptions.value = props.SafetyOptions
		if (props.editData) form.value = props.editData
	})
</script>

<style>
</style>